package com.gangquan360.smartadmin.module.order.saleorder.controller;

import com.gangquan360.smartadmin.common.domain.PageResultDTO;
import com.gangquan360.smartadmin.common.domain.ResponseDTO;
import com.gangquan360.smartadmin.module.order.saleorder.domain.dto.SaleOrderDTO;
import com.gangquan360.smartadmin.module.order.saleorder.domain.dto.SaleOrderQueryDTO;
import com.gangquan360.smartadmin.module.order.saleorder.service.SaleOrderService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * [ 销售订单表 ]
 *
 * @author wiggin
 * @version 1.0
 * @company wiggin
 * @copyright (c) 2019 wigginInc. All rights reserved.
 * @date 2020-03-31 19:43:21
 * @since JDK1.8
 */
@RestController
@Api(tags = {"销售订单表"})
public class SaleOrderController {

    @Autowired
    private SaleOrderService saleOrderService;

    @ApiOperation(value = "分页查询销售订单表",notes = "@author wiggin")
    @PostMapping("/saleOrder/page/query")
    public ResponseDTO<PageResultDTO<SaleOrderDTO>> queryByPage(@RequestBody SaleOrderQueryDTO queryDTO) {
        return saleOrderService.queryByPage(queryDTO);
    }

    @ApiOperation(value = "添加销售订单表",notes = "@author wiggin")
    @PostMapping("/saleOrder/add")
    public ResponseDTO<String> add(@RequestBody @Valid SaleOrderDTO addTO){
        return saleOrderService.add(addTO);
    }

    @ApiOperation(value="修改销售订单表",notes = "@author wiggin")
    @PostMapping("/saleOrder/update")
    public ResponseDTO<String> update(@RequestBody @Valid SaleOrderDTO updateDTO){
        return saleOrderService.update(updateDTO);
    }


    @ApiOperation(value="删除销售订单表",notes = "@author wiggin")
    @GetMapping("/saleOrder/delete/{id}")
    public ResponseDTO<String> delete(@PathVariable("id") Long id){
        return saleOrderService.delete(id);
    }


    @ApiOperation(value="详情销售订单表",notes = "@author wiggin")
    @GetMapping("/saleOrder/detail/{id}")
    public ResponseDTO<SaleOrderDTO> detail(@PathVariable("id") Long id){
        return saleOrderService.detail(id);
    }
}
